Transferring colors from a source object to a target object

ABSTRACT

A technique includes using a processor-based machine to determine a discrete color flow transformation to map target colors of a target object to source colors of a source object based at least in part on a first histogram indicating a color distribution of the target object and a second histogram of a color distribution indicating the source object. The technique includes determining a continuous color flow transformation to map the target colors to the source colors based at least in part on the discrete color flow transformation; and transforming the target colors of the target object to generate a third object based at least in part on the continuous color flow transformation.

BACKGROUND

In the course of editing an image, a user may want to transfer the colors of a particular object (called the “source object”) that is not part of the image to an object (called the “target object”) of the image. Stated differently, the source object may have a general color scheme, which the user desires to transfer to the target object. This task is rather challenging, however, due to the source and target color sets each typically containing a wide range of colors, with each of these colors typically having multiple shades.

BRIEF DESCRIPTION OF THE DRAWING

FIG. 1 is a schematic diagram of a color transformation system according to an example implementation.

FIGS. 2 and 4 are flow diagrams depicting techniques to transfer colors between source and target objects according to example implementations.

FIG. 3 is a schematic diagram of a physical machine according to an example implementation.

DETAILED DESCRIPTION

Referring to FIG. 1, a color transformation system 10 may be used for purposes of transferring colors that exist in a source image 20 to one or more regions of a target image 30. More specifically, the source image 20 may contain a particular source object 21, which contains colors that a user desires to transfer to a target object 31 of the target image 30. In this manner, a user identifies the source 21 and target 31 objects through scribbling, a bounding box or other user input, which supplies seed values to the color transformation system 10 indicative of subsets of pixels that are contained within the objects 21 and 31. Based on these seed values, a segmentation engine 40 of the color transformation system 10 identifies the boundaries of the source 21 and target 31 objects to thereby extract the objects 21 and 31 from the respective images 20 and 30. As a non-limiting example, the segmentation engine 40 may apply an auto-segmentation technique that is similar to the technique disclosed in U.S. patent application Ser. No. 13/114,690, entitled “Segmenting An Image,” which is filed concurrently herewith and is hereby incorporated by reference in its entirety. The segmentation engine 40 may use other segmentation schemes, in accordance with other implementations.

Regardless of the segmentation technique that is used, the segmentation engine 40 produces segmented images 50 and 60, which correspond to the source 21 and target 31 objects. In accordance with the systems and techniques that are disclosed herein, the color transformation system 10 processes the segmented images 50 and 60 for purposes of transferring the colors from the source object 21 to the target object 31 to produce a transformed object 124, which is essentially the target object 31 with the color scheme of the source object 21.

In general, the color transformation system 10 includes a discrete color flow transformation engine 100 and a continuous color flow transformation engine 120, which function as disclosed herein to generate the transformed object 124. In general, the discrete color flow transformation engine 100 generates a discrete color flow transformation to describe the transfer of color between the source 21 and target 31 objects based on histograms 70 and 80 that indicate the discrete color distributions of the segmented images 50 and 60, respectively. It is noted that the histograms 70 and 80 may be generated by the discrete color flow transformation engine 100 or by another processing entity, depending on the particular implementation.

As described herein, the continuous color flow transformation engine 120 determines a continuous color flow transformation to describe the transfer of color between the source 21 and target 31 objects based on statistics of the discrete color flow transformation, and based on the determined continuous color flow transformation, the continuous color flow transformation engine 120 generates the transformed object 124.

More specifically, in accordance with example implementations, the components of the color transformation system 10 work in conjunction to perform a technique 200 that is generally depicted in FIG. 2. Pursuant to the technique 200, histograms of source and target color distributions are first determined, pursuant to block 204. Next, a discrete color flow transformation is determined (block 208) to map target colors to source colors based on these source and target histograms. A continuous color flow transformation is then determined, pursuant to block 212, to map the target colors to the source colors based on statistics, which are associated with bins of the target histogram and are determined using the discrete color flow transformation. The colors of the target object 31 may then be transformed based on the determined continuous color flow transformation, pursuant to block 216.

Turning now to the more specific details, in accordance with some implementations, the discrete color flow transformation engine 100 first determines a color flow, which describes, in discrete terms, the mapping of the source colors to the target colors. In general, the discrete target and source color distributions may be described as a list of histogram bins with non-zero probabilities, along with their probabilities. For example, the histogram for the target object 31 may be described as “{(t_(i),p_(i) ^(t))}_(i=1) ^(n) ^(t) ,” where “t_(i)” represents the target bin-center; “p_(i) ^(t)” represents the corresponding probability mass for that bin; and “n_(t)” represents the number of bins. In a similar manner, the histogram for the source object 21 may be expressed as, “{(s_(j), p_(j) ^(s))}_(j=1) ^(n) ^(s) .”

One way to generate a discrete transform that describes the mapping of the colors from the source object 21 to the target object 31 is by solving a specific problem called, “the transportation problem.” In this approach, a flow between the target and source color distributions is represented “f_(ij),” where the indices i and j range over non-empty bins of the target and source color distributions, respectively. That is, the f_(ij) flow may be thought out as the part of target bin i, which is mapped to source bin j.

To guide this mapping, a color distance called “D(t,s)” is determined between the target and source colors. The color distance D(t,s) conveys how similar a target color is to a source color. As a non-limiting example, the color distance D(t,s) may be the ordinary L₂ norm distance between red-green-blue (RGB) vectors. However, the D(t,s) distance may take into account other factors. For example, if shadows are to be removed, a brightness-invariant distance may be used, which is described as follows:

$\begin{matrix} {{{D\left( {t,s} \right)} = {{\frac{t}{{t}_{1}} - \frac{s}{{s}_{1}}}}_{2}},} & {{Eq}.\mspace{14mu} 1} \end{matrix}$ where an RGB representation of color has been assumed. Other color distances may be used, in accordance with other example implementations. The color flows f_(ij) may be determined by minimizing an objective function, as described as follows:

$\begin{matrix} {{\min\limits_{\{ f_{ij}\}}{\sum\limits_{i = j}^{n_{t}}{\sum\limits_{j = 1}^{n_{s}}{f_{ij}{D\left( {t_{i},s_{j}} \right)}}}}},} & {{Eq}.\mspace{14mu} 2} \end{matrix}$ where the following constraints apply:

$\begin{matrix} {{{\sum\limits_{j = 1}^{n_{s}}f_{ij}} = p_{i}^{t}}{{i = 1},\ldots\mspace{14mu},n_{t},}} & {{Eq}.\mspace{14mu} 3} \\ {{{\sum\limits_{i = 1}^{n_{t}}f_{ij}} = p_{j}^{s}}{{j = 1},\ldots\mspace{14mu},n_{s},{and}}} & {{Eq}.\mspace{14mu} 4} \\ {f_{ij} \geq 0.} & {{Eq}.\mspace{14mu} 5} \end{matrix}$

The goal of minimizing the above-described objective function set forth in Eq. 2 is to map the target colors t_(i) to corresponding source colors s_(j) in such a way that the color distance D(t,s) between them is as small as possible. However, in practice, it may not be reasonably expected that each bin of the target distribution maps exactly to one bin of the source distribution. Therefore, the target bins may be distributed over several source bins, subject to the constraints imposed by Eqs. 3 and 4, which ensure a conservation of probability for both the target and source distributions.

Ensuring an exact conservation of probability may be too extreme, however, as this constraint assumes that the source and target regions contain exactly the same amounts of comparable colors. For example, an exemplary source object may contain 50% light red and 50% dark red colors; and the target object may contain 40% light blue colors and 60% dark blue colors. For this example, it is further assumed that it is desired to map target pixels with a given brightness to source pixels with a given brightness, independent of color; and it is also further assumed that the light blue and light red pixels have the same brightness as do the respective dark colors. The corresponding color distance is the brightness distance, which is “D(t,s)=|∥t∥₁−∥s∥₁|,” where “t” and “s” are RGB representations of color. In this case, by solving the above-described transportation problem, the conservation of probability constraints cause 10% of the dark blue section of the target image to appear in light red, which is not desirable.

To allow the source and target regions to contain disparate amounts of comparable colors, in accordance with exemplary implementations set forth herein, the conservation of probability constraints are relaxed by maintaining the constant imposed by Eq. 5, replacing the constraints expressed in Eqs. 3 and 4 with the corresponding constraints below:

$\begin{matrix} {{{p_{i}^{t}/\eta} \leq {\sum\limits_{j = 1}^{n_{s}}f_{ij}} \leq {\eta\; p_{i}^{t}}}{{i = 1},\ldots\mspace{14mu},n_{t},}} & {{Eq}.\mspace{14mu} 6} \\ {{{p_{j}^{s}/\eta} \leq {\sum\limits_{i = 1}^{n_{t}}f_{ij}} \leq {\eta\; p_{j}^{s}}}{{j = 1},\ldots\mspace{14mu},n_{s},{and}}} & {{Eq}.\mspace{14mu} 7} \end{matrix}$ adding the following equality constraint:

$\begin{matrix} {{\overset{n_{t}}{\sum\limits_{i,j}}f_{ij}} = 1.} & {{Eq}.\mspace{14mu} 8} \end{matrix}$

In Eqs. 6 and 7, “η” is a parameter greater than or equal to one, which describes the slackness of the conservation constraints. The constraint that is set forth in Eq. 8, which was forced implicitly in the above-described transportation problem, is now made explicit.

The role of η is described in the following theorem:

-   -   Consider the optimization problem with relaxed conservation         constraints. Modify (Eq. 6) to read

${{{p_{i}^{t}/\eta} + {\left( {1 - {1/\eta}} \right)ɛ}} \leq {\sum\limits_{j = 1}^{n_{s}}f_{ij}} \leq {\eta\; p_{i}^{t}}},$ for some ε>0 (ε can be chosen arbitrarily small). Then:

-   -   if η=1, the problem reduces to the ordinary transportation         problem; and     -   if η→∞, then for a fixed i, the only j for which f_(ij)>0 is         j=arg min_(j′) D(t_(i), s_(j)′)         This theorem states that the optimization problem with relaxed         conservation constraints interpolates between two cases: the         transportation problem, in which the parameter η is equal to         one; and the case in which each target color t_(i) flows         entirely to the source color s_(j), which is closest to it,         according to the color distance D(t_(i),s_(j)) for the η=∞         condition. In accordance with some exemplary implementations,         the parameter η is set to an intermediate value, such as two (as         a non-limiting example). Other values may be used for the         parameter η, in accordance with other example implementations.

The above-described optimization problem does not take into account the smoothness of the discrete color transformation. In this manner, it may be desirable for the color flows to be similar for similar target colors. This may be particularly advantageous, as the final, continuous color transformation is based on these flows; and a corresponding smoothness of the flows ensures that the continuous color transformation is also sufficiently smooth. Based on this criteria, the objective function expressed in Eq. 2 may be modified as follows, in accordance with example implementations:

$\begin{matrix} {{{\sum\limits_{i = j}^{n_{t}}{\sum\limits_{j = 1}^{n_{s}}{f_{ij}{D\left( {t_{i},s_{j}} \right)}}}} + {\gamma\;{\sum\limits_{i \neq i^{\prime}}{\omega_{i,i^{\prime}}{{\frac{f_{i}}{p_{i}^{t}} - \frac{f_{i^{\prime}}}{p_{i^{\prime\;}}^{t}}}}_{p}}}}},} & {{Eq}.\mspace{14mu} 9} \end{matrix}$ where “f_(i)” represents the vector “[f_(i,1) . . . f_(i,n) _(s) ]_(T);” “∥•∥_(p)” represents the p-norm; “ω_(i,i′)” represents a measure of similarity of t_(i) and t_(i′) colors; and “γ” represents a weighting factor between the transportation and smoothness terms. For pairs i and i′ with similar target colors, i.e., for pairs i and i′ where ω_(i,i′) is large, the normalized flows f_(i)•/p_(i) ^(t) and f_(i′)•/p_(i′) _(t) are similar. The reason for the normalization becomes apparent below but is explained briefly as follows. The normalized flow may be viewed as a probability distribution over source colors j, which correspond to a particular target color i. It is these probability distributions that are used for the final transformation, so it is these distributions that are desired to be smooth. In practice, a similarity measure of the form ω_(i,i′)=(d(t_(i,i′))+ε)^(−α) may be used, where “d” measures the distance between target colors; and “ε” and “α” are small positive parameters. Thus, the smoothed relaxed transportation problem may be set forth as follow:

$\begin{matrix} {{\min\;{f_{ij}\left( {{\sum\limits_{i = j}^{n_{t}}{\sum\limits_{j = 1}^{n_{s}}{f_{ij}{D\left( {t_{i},s_{j}} \right)}}}} + {\gamma\;{\sum\limits_{i \neq i^{\prime}}{\omega_{i,i^{\prime}}{{\frac{f_{i}}{p_{i}^{t}} - \frac{f_{i^{\prime}}}{p_{i^{\prime}}^{t}}}}_{p}}}}} \right)}},} & {{Eq}.\mspace{14mu} 10} \end{matrix}$ subject to the constraints that are imposed by Eqs. 5, 6, 7 and 8. If the norm p in Eq. 10 is greater than or equal to one, the minimization problem is a convex problem, which may be solved efficiently. It is noted that if the norm p is equal to two, then Eq. 10 may be solved as a quadratic problem.

The continuous color flow transformation engine 120 converts the discrete color flow transformation into a continuous color flow transformation. This transformation relies on determining a transformation (called “ø”), which maps a vector random variable (called “Z₁”) with a mean and covariance matrix (μ₁, σ₁), such that the transformed random variable Z₂=Ø(Z₁) has a mean and covariance matrix (μ₂, σ₂). In accordance with exemplary implementations, affine transformations are used to describe the transformed random variable Z₂ as follows: B ₁₂ Z ₁ +b ₁₂.  Eq. 10

As an example, if the random variables Z represent RGB color vectors, the covariance matrices may be described as follows:

$\begin{matrix} {{\sigma_{1} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & ɛ & 0 \\ 0 & 0 & ɛ \end{bmatrix}},{and}} & {{Eq}.\mspace{14mu} 11} \\ {{\sigma_{2} = \begin{bmatrix} ɛ & 0 & 0 \\ 0 & ɛ & 0 \\ 0 & 0 & 1 \end{bmatrix}},} & {{Eq}.\mspace{14mu} 12} \end{matrix}$ where “ε” is a relatively small number. Therefore, the initial distribution has various shades of red colors; and the final distribution has various shades of blue colors. For purposes of simplicity, it may be assumed that the means are zero means, for which case the most straightforward transformation is set forth below:

$\begin{matrix} {B_{12} = {{\sigma_{2}\sigma_{1}^{- 1}} = {\begin{bmatrix} ɛ & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & ɛ^{1} \end{bmatrix}.}}} & {{Eq}.\mspace{14mu} 13} \end{matrix}$

The transformation that is set forth in Eq. 13 ensures that the transformed variable Z₂ has a covariance matrix σ₂. However, this exemplary transformation significantly compresses the red color axis (by a factor of ε) and significantly expands the blue axis (by a factor of ε⁻¹). Therefore, the following transformation may alternatively be used:

$\begin{matrix} {B_{12} = {\begin{bmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{bmatrix}.}} & {{Eq}.\mspace{14mu} 14} \end{matrix}$ The transformation that is set forth in Eq. 14 does not lead to any stretching or compression in the color axes and is valid for ε=0.

The affine transformation that is set forth in Eq. 10, in accordance with exemplary implementations, is computed in a manner that preserves both the structure of the random variable Z₁ as well as minimizes the compression or stretching of the color axes. With the structure preservation, the two natural properties of moments and orthogonality of the principal directions are preserved, in accordance with example implementations. Regarding the preservation of the first two moments, the mean μ₂ matches the desired mean, as set forth below: μ₂ =E[Z ₂ ]=B ₁₂ E[Z ₁ ]+b ₁₂ =B ₁₂μ₁ +b ₁₂.  Eq. 15 In other words, the following relationships are satisfied: b ₁₂=μ₂ −B ₁₂μ₁, and Z ₂=Ø(Z ₁)=B ₁₂(Z ₁−μ₁)+μ₂.  Eq. 16 Moreover, the covariance matrix matches the desired covariance matrix, as described below:

$\begin{matrix} \begin{matrix} {\sigma_{2} = {E\left\lbrack {\left( {Z_{2} - \mu_{2}} \right)\left( {Z_{2} - \mu_{2}} \right)^{T}} \right\rbrack}} \\ {= {E\left\lbrack {{B_{12}\left( {Z_{1} - \mu_{1}} \right)}\left( {Z_{1} - \mu_{1}} \right)^{T}B_{12}^{T}} \right\rbrack}} \\ {{= {B_{12}\sigma_{1}B_{12}^{T}}},} \end{matrix} & {{Eq}.\mspace{14mu} 17} \end{matrix}$ where “T” represents the transposition operator.

To preserve the orthogonality of the principal directions, the principal directions of the covariance matrix σ₁ are preserved. Specifically, the orthogonality of the principal directions are preserved under the transformation ø. More specifically, U₁D₁U₁ ^(T) is assumed to be the eigendecomposition of the covariance matrix σ₁, such that the principal directions are the columns of the matrix U₁. Then, due to structural preservation, B₁₂U₁ is an orthogonal, though not orthonormal, matrix. Thus, (B₁₂U₁)^(T)(B₁₂U₁) is diagonal.

For purposes of minimizing the stretching or compression of the color axes, the amount of stretching or compression is measured in terms of the singular values of the matrix B₁₂. In particular, denoting the singular values of B₁₂ by “s_(i)(B₁₂),” the stretch of the transformation (called “Θ(Ø)”) may be defined as follows:

$\begin{matrix} {{{\Theta(\varnothing)} = {{\Theta\left( B_{12} \right)} = {\sum\limits_{i = 1}^{3}{\theta\left( {s_{i}\left( B_{12} \right)} \right)}}}},} & {{Eq}.\mspace{14mu} 18} \end{matrix}$ where “θ(s)” punishes values that are far away from one, i.e., values that compress or expand the color axes. Among the possibilities for θ are the following: θ(s)=|log(s)|, and  Eq. 19 θ(s)=max{s,s ⁻¹ }=e ^(|log(s)|).  Eq. 20

It is noted that where one of the covariance matrices is singular or nearly singular, a robust version of the stretch penalty may be used, such as the following: θ_(γ)(s)=min{θ(s),θ₀},  Eq. 21 In this manner, if θ(s) is determined pursuant to Eq. 20, then, θ₀ may be set equal to ten, as a non-limiting example.

Using the properties described above, the following optimization may be used:

$\begin{matrix} {{{\min\limits_{B_{12}}{{\Theta\left( B_{12} \right)}\mspace{14mu}{subject}\mspace{14mu}{to}\mspace{14mu} B_{12}\sigma_{1}B_{12}^{T}}} = \sigma_{2}}{{and}\mspace{14mu}\left( {B_{12}U_{1}} \right)^{T}\left( {B_{12}U_{1}} \right)\mspace{14mu}{is}\mspace{14mu}{{diagonal}.}}} & {{Eq}.\mspace{14mu} 22} \end{matrix}$ The solution to the optimization that is set forth in Eq. 22 is contained in the following theorem:

-   -   Let σ_(k)=U₁D₁U₁ ^(T) and let d_(k;i)=(D_(k))_(ii) for k=1, 2         and i=1, 2, 3. Then the solution to (Eq. 22) is B₁₂*=U₂S₁₂P₁₂U₁         ^(T), where         -   P₁₂ is a permutation matrix, corresponding to the             permutation π, which solves

$\min\limits_{\pi}{\sum\limits_{i = 1}^{3}{\theta\left( \left( {d_{2,i}/d_{1,{\pi{(i)}}}} \right)^{\frac{1}{2}} \right)}}$

-   -   This is an instance of the assignment problem, which can be         solved, e.g., by the technique disclosed in J. Munkres,         “Algorithms For The Assignment and Transportation Problems,” J.         Siam, pages 32-38, 1957.         -   S₁₂ is a diagonal matrix whose ii^(th) entry is             (d_(2;i)=d_(1;π(i)))1=2 (where π is as above).

The determination of the transformation ø using the above-described structure preservation and stretch minimization is referred to as the “Stretch-Minimizing Structure-Preserving (SMSP) transformation” herein. It is noted that the SMSP transformation is relatively easy to determine, using diagonalization and singular value decomposition of small (3×3) matrices, as well the solution of a relatively small assignment problem (again using relatively small 3×3 matrices).

As described above, the discrete color flows f_(ij) map the discrete target color distribution to the discrete source color distribution. This discrete color flow transformation is transformed into a continuous color flow transformation using the above-described SMSP transformations as follows.

In general, the normalized flow for each target bin i and each source bin j is viewed as probability distributions, which identify the mapping between the target and source colors. The normalized flows lead to the definition of pairs of random variables for each target bin i. The mapping between the source random variable to the target random variable is accomplished using an SMSP transformation.

The normalized target (Eq. 23) and source (Eq. 24) flows are set forth below:

$\begin{matrix} {{p_{ij}^{ts} = \frac{f_{ij}}{\sum\limits_{j^{\prime}}f_{{ij}^{\prime}}}},{and}} & {{Eq}.\mspace{14mu} 23} \\ {p_{ij}^{ts} = {\frac{f_{ij}}{\sum\limits_{i^{\prime}}f_{i^{\prime}j}}.}} & {{Eq}.\mspace{14mu} 24} \end{matrix}$ The normalized target flow provides the distribution of source colors corresponding to the i^(th) target color. In a similar fashion, the normalized source flow provides the distributions of target colors corresponding to the j^(th) source color. These normalized flows are used to determine statistics, i.e., means and covariance matrices, of a pair of vector random variables associated with the i^(th) target color.

First discussed below is the source random variable, which is associated with target bin i. The distribution of source bins associated with target color i is the normalized source flow called “p_(ij) ^(ts).” The statistics of the source random variable associated with bin i, which are the mean {tilde over (μ)}_(i) ^(s) and covariance matrix {tilde over (σ)}_(i) ^(s) are then determined. The mean and second moment associated with each source bin may be described as follows: μ_(j) ^(s) =E[s|sεbin_(j)], and  Eq. 25 ν_(j) ^(s) =E[ss ^(T) ]sεbin_(j).  Eq. 26 In practice, μ_(j) ^(s) and ν_(j) ^(s) are determined from the samples within bin j in the standard way. The statistics of the source colors associated with bin i may then be determined as follows:

$\begin{matrix} {{{\overset{\sim}{\mu}}_{i}^{s} = {\sum\limits_{j}{p_{ij}^{ts}\mu_{j}^{s}}}},{and}} & {{Eq}.\mspace{14mu} 27} \\ {{\overset{\sim}{\sigma}}_{i}^{s} = {{\sum\limits_{j}{p_{ij}^{ts}v_{j}^{s}}} - {{{\overset{\sim}{\mu}}_{i}^{s}\left( {\overset{\sim}{\mu}}_{i}^{s} \right)}^{T}.}}} & {{Eq}.\mspace{14mu} 28} \end{matrix}$ Regarding the target random variable associated with target bin i, the distribution of target bins associated with target color i are first examined. The normalized target flow p_(ij) ^(ts) indicates that the source bins j associated with target bin i; but for each source bin j, the normalized source flow p_(ji) ^(st) indicates the target bins i associated with that bin. Thus, the normalized target and source flows are combined to understand which target bins are related. In this context, “related” means that the target bins map to the same source bins j. Specifically, this is set forth below:

$\begin{matrix} {{p_{{ii}^{\prime}}^{tt} = {\sum\limits_{j}{p_{ij}^{ts}p_{{ji}^{\prime}}^{ts}}}},} & {{Eq}.\mspace{14mu} 29} \end{matrix}$ or in matrix notation p^(tt)=p^(ts)p^(st). This distribution relates target bin i to target bin i′. Here, p_(ii) is relatively large if target bins i and i′ map to similar source bins and relatively small if this is not the case. The p^(tt) matrix is a stochastic matrix.

Given p_(ii) ^(tt), the statistics of the target random variable associated with bin i are then determined, i.e., the covariance matrix {tilde over (σ)}_(i) ^(t) and the mean matrix {tilde over (μ)}_(i) ^(t) are determined. This process is the same as the case for source statistics. If it is assumed that the mean and second moment are associated with each target bin, then the following relationships are obtained: μ_(i) ^(t) =E[t|tεbin_(i)], and  Eq. 30 ν_(i) =E[ss ^(T) |yεbin_(i)].  Eq. 31 In practice, μ_(i) ^(t) and ν_(i) ^(t) are computed from the samples within bin i in the standard way. Then, statistics of the target colors associated with bin i are determined as follows:

$\begin{matrix} {{{\overset{\sim}{\mu}}_{i}^{t} = {\sum\limits_{i^{\prime}}{p_{{ii}^{\prime}}^{tt}\mu_{i}^{t}}}},{and}} & {{Eq}.\mspace{14mu} 32} \\ {{{\overset{\sim}{\sigma}}_{i}^{t} = {{\sum\limits_{i^{\prime}}{p_{{ii}^{\prime}}^{tt}v_{i^{\prime}}^{t}}} - {{\overset{\sim}{\mu}}_{i}^{t}\left( {\overset{\sim}{\mu}}_{i}^{t} \right)}^{T}}},} & {{Eq}.\mspace{14mu} 33} \end{matrix}$

Given the above-described determination of the pairs of random variables for each target bin i, the optimal transformation for bin i is next determined. In particular, a distribution with mean and covariance matrix ({tilde over (μ)}_(i) ^(t),{tilde over (σ)}_(i) ^(t)) is transformed to a mean and covariance matrix ({tilde over (μ)}_(i) ^(s),{tilde over (σ)}_(i) ^(s)). To do so, the resulting transformation, called “ψ_(i)(t)” is disclosed herein and is described as follows:

$\begin{matrix} {{{\psi(t)} = {\sum\limits_{i = 1}^{n_{i}}{{w_{i}(t)}{\psi_{i}(t)}}}},} & {{Eq}.\mspace{14mu} 34} \end{matrix}$ where the non-negative weights “w_(i)(t)” sum to one. In other words,

${{\sum\limits_{i}{w_{i}(t)}} = 1},{{{with}\mspace{14mu}{w_{i}\left( t_{i} \right)}} = 1.}$ The overall transformation ψ_(i)(t) interpolates the bin-by-bin transformations ψ_(i)(t). In accordance with exemplary implementations, the weights w_(i)(t) may be determined as follows:

$\begin{matrix} {{{w_{i}(t)} = \frac{{d\left( {t,t_{i}} \right)}^{- \alpha}}{\sum\limits_{i^{\prime}}{d\left( {t,t_{i^{\prime}}} \right)}^{- \alpha}}},} & {{Eq}.\mspace{14mu} 35} \end{matrix}$ where “d” represents the distance between two target colors and “α” is greater than zero. An interesting property of this algorithm occurs when the smoothness weight γ goes to infinity (∞) in the computation of the color flow in the smoothed relaxation problem. If (μ_(tot) ^(s),σ_(tot) ^(s)) is assumed to be the mean and covariance matrix of the entire collection of source vectors (i.e., ignoring the histogram bins and simply pooling all source vectors together) and likewise for (μ_(tot) ^(t),σ_(tot) ^(s)) then the following holds true:

-   -   Let the color flow f_(ij) be computed as the solution to the         Smoothed Relaxed Transportation Problem, with η=1 and γ→∞. Then         the color transformation ψ(t)     -   is the SMSP transformation from the random variable with mean         and covariance matrix μ_(tot) ^(t),σ_(tot) ^(t) to the random         variable with mean and covariance matrix μ_(tot) ^(s),σ_(tot)         ^(s)         The above-recited theorem is quite useful, as it states that as         the smoothness term becomes the dominant term, the         transformation approach is the transformation that is achieved         by considering the source and target distributions to be         unimodal.

To summarize, in accordance with an example implementation, a technique 300 that is depicted in FIG. 4 may be used for purposes of mapping colors from a source object to a target object. Pursuant to the technique 300, a discrete color flow transformation is determined (block 304) to map target colors to source colors based on a source histogram, a target histogram, relaxed probability conservation constraints and a desired smoothness of the color flow. Next, the technique 300 includes determining (block 308), for each bin i of target histogram, statistics of a target random variable associated with the bin i based on the discrete color flow transformation. For each bin i of the target histogram, the technique 300 includes determining (block 312) a transformation to map the target random variable to the source random variable such that the transformation preserves the structure of the target random variable and regulates stretching and compression of the color axes. Finally, the technique 300 includes transformation (block 316) the target colors based on the determined transformations.

Referring to FIG. 3, in accordance with example implementations, the systems and techniques that are disclosed herein may be implemented in, for example, a system that includes at least one physical machine 220. In this context, a “physical machine” indicates that the machine is an actual machine made up of executable program instructions and hardware. Examples of physical machines include computers (e.g., application servers, storage servers, web servers, etc.), communications modules (e.g., switches, routers, etc.) and other types of machines. The physical machine(s) may be located within one cabinet (or rack), or alternatively, the physical machine(s) may be located in multiple cabinets (or racks).

In accordance with a specific example that is disclosed herein, the physical machine 220 contains machine executable program instructions and hardware 222 that executes the instructions for purposes of implementing all or parts of the color transformation system 10 (see FIG. 1), i.e., transferring color from a source image to a target image, using all or selected parts of the techniques 200 (see FIG. 2) and/or 300 (see FIG. 4), which are disclosed herein. In some implementations, execution of the machine executable instructions causes the physical machine 220 to create a color transfer engine 250 for purposes of performing all or parts of one or more of the exemplary techniques that are disclosed herein, such as the techniques 200 and/or 300. In this manner, color transfer engine 250 may cause the physical machine 220 to provide a user interface 252 that allows a user to select regions of the target and source images to be segmented, thereby facilitating the generation of seed values for determining the colors of source and target objects; determine corresponding histograms of source and target colors; determine a discrete color flow transformation to map target colors to source colors; determine a continuous color flow transformation to map target colors to source colors; transform colors of a target object based on a determined continuous color flow transformation; etc.

It is noted that FIG. 3 is merely an example of an architecture that might be used to perform the color transfer techniques that are disclosed herein. In this regard, an architecture to perform the techniques that are disclosed herein may include one or multiple additional physical machines 220. Thus, all or part of any of the techniques that are disclosed herein, such as the techniques 200 and 300, may be implemented on a single physical machine or on more than two physical machines, depending on the particular implementation. Moreover, although the physical machine 220 is depicted in FIG. 3 as being contained within a box, it is noted that the physical machine 220 may be a distributed machine having multiple nodes, which provide a distributed and parallel processing system.

Regarding more specific details of an exemplary implementation, the machine executable instructions of the physical machine 220 may include one or multiple applications 246, an operating system 240 and one or multiple device drivers 244 (which may be part of the operating system 240). In general, the machine executable instructions of the physical machine 220 may be stored in non-transitory storage, such as in a memory 228 of the physical machine 220. In this manner, the machine executable instructions may be stored in a non-transitory medium or non-transitory media, such as in system memory, in a semiconductor memory, in removable storage, in optical storage, in magnetic storage, in non-removable storage, in storage separate (local or remote) from the physical machine 220, etc., depending on the particular implementation. The memory 228 may also store data indicative of the source and target images; histograms describing color distributions in these images; data indicating results of segmentation; data indicative of the discrete color flow transformation; data indicative of statistics; data indicative of a continuous color flow transformation; etc., depending on the particular implementation.

In addition to the memory 228, the hardware 222 of the physical machine 220 includes one or multiple processors that execute the machine executable instructions, such as one or multiple central processing units (CPUs) and/or one or multiple processing cores of the CPU(s) 224. The hardware 222 may contain various other components, such as a network interface card (NIC) 232 and a display 236 to allow a user to select objects of the source and target images for segmentation; view the results of the color transfer in the corresponding transformed object; etc.

While the present invention has been described with respect to a limited number of embodiments, those skilled in the art, having the benefit of this disclosure, will appreciate numerous modifications and variations therefrom. It is intended that the appended claims cover all such modifications and variations as fall within the true spirit and scope of this present invention. 

What is claimed is:
 1. A method comprising: using a processor-based machine to determine a discrete color flow transformation to map target colors of a target object to source colors of a source object based at least in part on a first histogram indicating a color distribution of the target object and a second histogram of a color distribution indicating the source object; determining a continuous color flow transformation to map the target colors to the source colors based at least in part on the discrete color flow transformation; and transforming the target colors of the target object to generate a third object based at least in part on the continuous color flow transformation.
 2. The method of claim 1, wherein the act of using the processor-based machine to determine the discrete color flow transformation comprises not completely conserving probability for the color distributions.
 3. The method of claim 1, wherein the act of using the processor-based machine to determine the discrete color flow transformation comprises determining a plurality of color flows interrelating bins of the first histogram to bins of the second histogram and regulating a smoothness of the discrete transformation to cause flows for substantially similar colors of the target object to be substantially the same.
 4. The method of claim 1, wherein the act of determining the continuous color flow transformation comprises determining the continuous color flow transformation based at least in part on statistics associated with bins of the first histogram.
 5. The method of claim 4, further comprising determining the statistics, the determining comprising: for each bin of the first histogram, determining first statistics of a random variable associated with the bin and associated with the target object, based on the discrete color flow transformation; and for each bin of the first histogram, determining second statistics of a random variable associated with the bin and associated with the source object, based on the discrete color flow transformation.
 6. The method of claim 5, wherein the act of determining the continuous color flow transformation comprises: for each bin, determining a transform interrelating the random variable associated with the bin and associated with the target object to the random variable associated with the bin and associated with the source object.
 7. The method of claim 6, wherein the act of determining the transforms comprises preserving a structure associated with each of the random variables associated with the target object.
 8. The method of claim 6, wherein the act of determining the transforms comprises regulating stretching of color axes introduced by the transforms.
 9. A system comprising: a memory to store data indicative of a first histogram indicating a color distribution of a target object and a second histogram indicating a color distribution of a source object; and at least one processor-based engine to: determine a discrete color flow transformation to map target colors of the target object to source colors of the source object based at least in part on the first and second histograms; determine a continuous color flow transformation to map the target colors to the source colors based at least in part on the discrete color flow transformation; and transform the target colors of the target object to generate a third object based at least in part on the continuous color flow transformation.
 10. The system of claim 9, wherein engine is adapted to not completely conserve probability for the color distributions in the determination of the discrete color flow transformations.
 11. The system of claim 9, wherein the engine is adapted to determine a plurality of color flows interrelating bins of the first histogram to bins of the second histogram and to regulate a smoothness of the discrete transformation to cause flows for substantially similar colors of the target object to be substantially the same.
 12. The system of claim 9, wherein the engine is adapted to: for each bin of the first histogram, determine first statistics of a random variable associated with the bin and associated with the target object, based on the discrete color flow transformation; and for each bin of the first histogram, determine second statistics of a random variable associated with the bin and associated with the source object, based on the discrete color flow transformation.
 13. The system of claim 12, wherein the engine is adapted to: for each bin, determine a transform interrelating the random variable associated with the bin and associated with the target object to the random variable associated with the bin and associated with the source object.
 14. The system of claim 12, wherein the engine is adapted to: preserve a structure associated with each of the random variables associated with the target object; and regulate stretching of color axes introduced by the transforms.
 15. An article comprising a machine readable storage medium storing instructions that when executed by at least one processor cause said at least one processor to: determine a discrete color flow transformation to map target colors of a target object to source colors of a source object based at least in part on a first histogram indicating a color distribution of the target object and a second histogram indicating a color distribution of the source object; determine a continuous color flow transformation to map the target colors to the source colors based at least in part on the discrete color flow transformation; and transform the target colors of the target object to generate a third object based at least in part on the continuous color flow transformation.
 16. The article of claim 15, the storage medium storing instructions that when executed by said at least one processor cause said at least one processor to determine a plurality of color flows interrelating bins of the first histogram to bins of the second histogram and to regulate a smoothness of the discrete transformation to cause flows for substantially similar colors of the target object to be substantially the same.
 17. The article of claim 15, the storage medium storing instructions that when executed by said at least one processor cause said at least one processor to: for each bin of the first histogram, determine first statistics of a random variable associated with the bin and associated with the target object, based on the discrete color flow transformation; and for each bin of the first histogram, determine second statistics of a random variable associated with the bin and associated with the source object, based on the discrete color flow transformation.
 18. The article of claim 17, the storage medium storing instructions that when executed by said at least one processor cause said at least one processor to: for each bin, determine a transform interrelating the random variable associated with the bin and associated with the target object to the random variable associated with the bin and associated with the source object.
 19. The article of claim 18, the storage medium storing instructions that when executed by said at least one processor cause said at least one processor to: selectively weight the transforms to generate the third object.
 20. The article of claim 18, the storage medium storing instructions that when executed by said at least one processor cause said at least one processor to: preserve a structure associated with each of the random variables associated with the target object; and regulate stretching of color axes introduced by the transforms. 